// https://leetcode.cn/problems/assign-cookies/
// Created by ade on 2022/8/5.
//
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class Solution {
public:
    // 每个孩子最多拿一个饼干，饼干不可分割
    int findContentChildren(vector<int> &g, vector<int> &s) {
        sort(g.begin(), g.end());// 7,8,9,10
        sort(s.begin(), s.end());// 5,6,7,8 饼干
        int gi = 0;
        int si = 0;
        int count = 0;

        for (; si < s.size(); si++) {
            if(gi >= g.size()) break;
            if (g[gi] <= s[si]) {
                gi++;
                count++;
            }
        }
        return count;
    }
};

int main() {
    Solution so;

}